package com.yunpeng.aidevice.cms.web.controllers;

import com.alibaba.fastjson.JSONObject;
import com.yunpeng.aidevice.biz.service.IUserLoginBizService;
import com.yunpeng.common.dto.Result;
import com.yunpeng.common.util.ParametersCheckUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * MerchantSystemController
 *
 * @author : Moore(hemw)
 * @date : 2020-04-29
 */
@RestController
@RequestMapping("/api/merchantSystem")
public class MerchantSystemController {


    @Resource
    private IUserLoginBizService userLoginBizService;

    /**
     * 业务系统登录
     *
     * @param requestParam
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "login", method = RequestMethod.POST)
    public Result<JSONObject> login(@RequestBody JSONObject requestParam) {
        ParametersCheckUtil.mapIsNotNullOrderEmpty(requestParam, "没有传递任何参数");
        String userCode = requestParam.getString("userCode");
        String password = requestParam.getString("password");
        ParametersCheckUtil.isNotBlank(userCode, "无效的用户代码");
        ParametersCheckUtil.isNotBlank(password, "无效的密码");
        return userLoginBizService.loginMerchantSystem(userCode, password);
    }

}
